package com.fsm.system.controller;

import com.fsm.common.log.config.LogData;
import com.fsm.common.log.entity.dto.OperationEnum;
import com.fsm.common.log.entity.dto.SystemTypeEnum;
import com.fsm.common.tools.Result.Result;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.beans.factory.annotation.Autowired;
import com.fsm.system.entity.TSystemUser;
import com.fsm.system.service.TSystemUserService;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;

/**
 *  控制层。
 *
 * @author 翻山鸣
 * @since 2024/04/20
 */
@RestController
@Tag(name = "系统用户接口")
@RequestMapping("/tSystemUser")
public class TSystemUserController {

    @Autowired
    private TSystemUserService tSystemUserService;
    /**
     * 获取用户信息
     *
     * @param
     * @return
     */
    @LogData(value = "获取用户信息",operation = OperationEnum.SELECT,systemTypeEnum = SystemTypeEnum.BACKEND)

    @GetMapping("getUserInfo")
    @Operation(summary="获取用户信息",description="获取用户信息")
    public Result getUserInfo() throws Exception{
        return tSystemUserService.getUserInfo();
    }


    /**
     * 添加系统用户
     *
     * @param
     * @return
     */
    @LogData(value = "添加系统用户",operation = OperationEnum.INSERT,systemTypeEnum = SystemTypeEnum.BACKEND)
    @PostMapping("addSystemUser")
    @Operation(summary="添加系统用户",description="添加系统用户")
    public Result addSystemUser(@RequestBody TSystemUser tSystemUser) throws Exception{
        return tSystemUserService.addSystemUser(tSystemUser);
    }

    /**
     * 删除系统用户
     *
     * @param
     * @return
     */
    @LogData(value = "删除系统用户",operation = OperationEnum.DELETE,systemTypeEnum = SystemTypeEnum.BACKEND)
    @PostMapping("deleteSystemUser")
    @Operation(summary="删除系统用户",description="删除系统用户")
    public Result deleteSystemUser(@RequestBody TSystemUser tSystemUser) throws Exception{
        return tSystemUserService.deleteSystemUser(tSystemUser);
    }

    /**
     * 更新系统用户
     *
     * @param tSystemUser
     * @return
     */
    @LogData(value = "更新系统用户",operation = OperationEnum.UPDATE,systemTypeEnum = SystemTypeEnum.BACKEND)
    @PostMapping("updateSystemUser")
    @Operation(summary="更新系统用户",description="更新系统用户")
    public Result updateSystemUser(@RequestBody TSystemUser tSystemUser) throws Exception{
        return tSystemUserService.updateSystemUser(tSystemUser);
    }

    /**
     * 分页查询系统用户
     *
     * @param
     * @return 分页对象
     */
    @LogData(value = "分页查询系统用户",operation = OperationEnum.SELECT,systemTypeEnum = SystemTypeEnum.BACKEND)
    @PostMapping("pageSystemUser")
    @Operation(summary="分页查询系统用户",description="分页查询系统用户")
    public Result pageSystemUser(@RequestBody TSystemUser tSystemUser) throws Exception{
        return tSystemUserService.pageSystemUser(tSystemUser);
    }

    /**
     * 查询系统列表
     *
     * @param
     * @return 分页对象
     */
    @LogData(value = "查询系统用户列表",operation = OperationEnum.SELECT,systemTypeEnum = SystemTypeEnum.BACKEND)
    @PostMapping("getSystemUserList")
    @Operation(summary="查询系统用户列表",description="查询系统用户列表")
    public Result getSystemUserList(@RequestBody TSystemUser tSystemUser) throws Exception{
        return tSystemUserService.getSystemUserList(tSystemUser);
    }

    /**
     * 通过ID查询系统管理ID
     *
     * @param
     * @return 分页对象
     */
    @LogData(value = "通过ID查询系统用户",operation = OperationEnum.SELECT,systemTypeEnum = SystemTypeEnum.BACKEND)
    @PostMapping("getSystemUserById")
    @Operation(summary="通过ID查询系统用户",description="通过ID查询系统用户")
    public Result getSystemUserById(@RequestBody TSystemUser tSystemUser) throws Exception{
        return tSystemUserService.getSystemUserById(tSystemUser);
    }

    /**
     * 通过用户ID获取菜单
     *
     * @param
     * @return 分页对象
     */
    @LogData(value = "通过用户ID获取菜单",operation = OperationEnum.SELECT,systemTypeEnum = SystemTypeEnum.BACKEND)
    @PostMapping("getMenuByUserId")
    @Operation(summary="通过用户ID获取菜单",description="通过用户ID获取菜单")
    public Result getMenuByUserId(@RequestBody TSystemUser tSystemUser) throws Exception{
        return tSystemUserService.getMenuByUserId(tSystemUser);
    }

    /**
     * 导出用户信息
     *
     * @param
     * @return 分页对象
     */
    @LogData(value = "导出用户信息",operation = OperationEnum.EXPORT,systemTypeEnum = SystemTypeEnum.BACKEND)

    @PostMapping("uploadUser")
    @Operation(summary="导出用户信息",description="导出用户信息")
    public Result uploadUser(@RequestBody TSystemUser tSystemUser, HttpServletResponse response) throws Exception{
        return tSystemUserService.uploadUser(tSystemUser,response);
    }
}
